import { useEffect, useRef } from "react";
// 组件卸载时运行
export const useUnmount = (fn: () => void) => {
  const fnRef = useRef(fn);
  fnRef.current = fn;
  useEffect(() => ()=>fnRef.current(), []);
};